import sys, urllib 
from HTMLParser import HTMLParser

#Analyze the web page        
class Analyzer(HTMLParser):
    def analyze(self,data,output):
        print 'analyze data'
        self.feed(data)
        self.close()
        
    def handle_starttag(self, tag, attrs):
        print "Encountered the beginning of a %s tag" % tag

    def handle_endtag(self, tag):
        print "Encountered the end of a %s tag" % tag

        
    
#Retrieve the web page and parse the html tags. Extract the useful information
class WebCrawler: 
    def __init__(self,analyzer):
        self.m_analyzer=analyzer
        self.m_tags=['title', 'language', 'hyperlinks','table'] 

    def retrieve(self, url):
        reader=urllib.urlopen(url)
        data=reader.read()
        reader.close()
        return data


def main():
    print 'main'
    wc=WebCrawler(Analyzer())
    wc.retrieve('http://www.javaeye.com')
    

if __name__=='__main__':
    main()